
source ~/local/gcc-aarch64.bashrc

G_PREFIX=aarch64-linux-gnu-
#aarch64-none-elf-gcc

SOURCE=$1

[ "$SOURCE" = "" ] && echo "$0 source_name " && exit 1

mkdir build_$SOURCE
cd build_$SOURCE

# SOURCE=../$1

ENTRY_POINT=" -e 0x0 -Ttext 0x0 "
ENTRY_POINT=" -e main -Ttext 0x0 "

${G_PREFIX}gcc -static -c ../${SOURCE}.c 
${G_PREFIX}ld $ENTRY_POINT -static ${SOURCE}.o -o ${SOURCE}
#${G_PREFIX}objdump -d a.out >a.asm
${G_PREFIX}objdump -d ${SOURCE} >${SOURCE}.asm
${G_PREFIX}objcopy -O binary ${SOURCE} ${SOURCE}.bin 
../bin_flash ${SOURCE}.bin ${SOURCE}.mem
